package com.itheima.d3_thread_safe;

public class Ticket implements Runnable{
    private int ticket = 100;
    private int sum = 0;

    @Override
    public void run() {
        while(true){
            if(ticket <= 0){
                break;
            }else {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                ticket--;
                System.out.println(Thread.currentThread().getName()+"在卖票，还剩 "+ticket+" 张"+"总卖："+ ++sum);
            }


        }



    }

}
